/******************************************************************************/
package jamie.org.sil.www.usxUtils;

/******************************************************************************/
/**
 * A converter-specific exception class.  I've had to use an unchecked
 * exception, because in some cases this is raised by classes which override
 * generic routines (eg those you use in conjunction with Xerces), and the
 * signature of those routines does not include an exception.
 * <p>
 *
 * See {@link IncidentHandler} for more information about exception handling
 * etc.
 *
 * @author ARA "Jamie" Jamieson
 */

public class ConverterException extends RuntimeException
{
  /****************************************************************************/
  /****************************************************************************/
  /**                                                                        **/
  /**                                Public                                  **/
  /**                                                                        **/
  /****************************************************************************/
  /****************************************************************************/

  /****************************************************************************/
  /**
   * Constructor.
   *
   * @param message
   */

  public ConverterException (Action action, Log log, String message)
  {
    super(message);
    m_Action = action;
    m_Log = log;
    try { IncidentHandler.instance().handleException(this); } catch (Exception e) {}
  }

 
  /****************************************************************************/
  /** Actions to be taken in the light of this exception. */
      
  public enum Action
  { 
    None(0), 
    AbandonRunWhenever(1), 
    AbandonRunNow(2), 
    AbandonFileWhenever(3), 
    AbandonFileNow(4);
    
    public int getOrdinal () { return m_Ordinal; }
    private Action (int ordinal) { m_Ordinal = ordinal; }
    private int m_Ordinal;
  }


  /****************************************************************************/
  /** Logging */
  
  public enum Log { None, Error, Warning, Information };

  
  
  /****************************************************************************/
  /**
      Returns an indication of the action to be taken in the light of this
      exception.
      
      @return Action.
  */
      
  public Action getAction () { return m_Action; }


  /****************************************************************************/
  /**
      Returns an indication of the log to which this exception is to be
      written.
      
      @return Log.
  */
      
  public Log getLog () { return m_Log; }




  
  
  /****************************************************************************/
  /****************************************************************************/
  /**                                                                        **/
  /**                               Private                                  **/
  /**                                                                        **/
  /****************************************************************************/
  /****************************************************************************/

  /****************************************************************************/
  private Action m_Action;
  private Log m_Log;
}

